<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //父类
        function Parent(name){
            this.name = name || '干饭人';
            this.run = function(){
                console.log(this.name + '干饭');
            }
        }
        Parent.prototype.say = function(){
            console.log('我是' + this.name);
        }

        //子类
        function Child(){
        }
        //将父类的实例转为子类的原型
        Child.prototype = new Parent();

        let son = new Child();
        son.say();//我是干饭人
        son.run();干饭人干饭
        /*
        问题：1.原型对象（引用类型）的属性会被所有实例共享
              2.创建子类实例(son)时无法向父类构造函数传参数
        */
    </script>
</body>
</html>